package com.common.security.exceptions;

import com.common.security.abstracts.AbstractRuntimeException;

/**
 * Error code range: 1101 - 1120
 * 
 * @author Ady
 *
 */
public class UserException extends AbstractRuntimeException {
	
	private static final long serialVersionUID = 1L;
	
	public static final int USER_NOT_FOUND = 1101;
	private static final String MESSAGE_USER_NOT_FOUND = "The user with the provided data was not found";	

	public static final int MULTIPLE_USERS_FOUND = 1102;
	private static final String MESSAGE_MULTIPLE_USERS_FOUND = "More than one user was found with the " +
			"provided data";
	
	public static final int DUPLICATE_USERNAME = 1103;
	private static final String MESSAGE_DUPLICATE_USERNAME = "The username already exists in the " +
			"database";
	
	public static final int USER_TYPE_NOT_AVAILABLE = 1104;
	private static final String MESSAGE_USER_TYPE_NOT_AVAILABLE = "The provided user type is unavailable";

	
	public UserException(int code) {
		super(code, getMessage(code));
	}
	
	private static String getMessage(int code) {
		switch (code) {
			case USER_NOT_FOUND: {
				return MESSAGE_USER_NOT_FOUND;
			}
			case MULTIPLE_USERS_FOUND: {
				return MESSAGE_MULTIPLE_USERS_FOUND;
			}
			case DUPLICATE_USERNAME: {
				return MESSAGE_DUPLICATE_USERNAME;
			}
			case USER_TYPE_NOT_AVAILABLE: {
				return MESSAGE_USER_TYPE_NOT_AVAILABLE;
			}
			default: {
				return MESSAGE_ERROR_NOT_FOUND;
			}
		}
	}
}
